home *** CD-ROM | disk | FTP | other *** search
/ The National Palace Museum Experience / The National Palace Museum Experience.iso / Programs / Index.dxr / 00110_control handlers.ls < prev    next >
Encoding:
Text File  |  1998-11-19  |  5.7 KB  |  210 lines

  1. global groommouseupslist, groommousedownslist, hiliterect, roomscrollpos, roomscrolllinesize, roombarsprite, roomleftofscroll, roomrightofscroll, roomtotalscroll, roomcontentsprite, roommaxscroll, roomlist, returnflag, originalloc, currlabel, endSprite
  2.  
  3. on initroomcontrols
  4.   set groommousedownslist to []
  5.   set groommouseupslist to []
  6.   setAt(groommouseupslist, hiliterect, 0)
  7.   setAt(groommousedownslist, hiliterect, 0)
  8. end
  9.  
  10. on addroomcontrol channel, chotspots, cactions, whichway
  11.   if not listp(chotspots) or not listp(cactions) then
  12.     return #badcontrol
  13.   end if
  14.   if count(chotspots) <> count(cactions) then
  15.     return #badcontrol
  16.   end if
  17.   if whichway = #down then
  18.     setAt(groommousedownslist, channel, [chotspots, cactions])
  19.   else
  20.     setAt(groommouseupslist, channel, [chotspots, cactions])
  21.   end if
  22. end
  23.  
  24. on deleteroomcontrol channel, whichway
  25.   if (whichway = #up) or (whichway = #both) then
  26.     setAt(groommouseupslist, channel, 0)
  27.   end if
  28.   if (whichway = #down) or (whichway = #both) then
  29.     setAt(groommousedownslist, channel, 0)
  30.   end if
  31. end
  32.  
  33. on hitroomcontrol whichway
  34.   global spriteNum
  35.   set me to the clickOn
  36.   set hitpoint to point(the mouseH - the left of sprite me, the mouseV - the top of sprite me)
  37.   if whichway = #down then
  38.     set controlslist to groommousedownslist
  39.     if the name of the mouseMember contains "light" then
  40.       puppetSound(2, "Button")
  41.       updateStage()
  42.     end if
  43.   else
  44.     set controlslist to groommouseupslist
  45.   end if
  46.   set mycontrol to getAt(controlslist, me)
  47.   if not listp(mycontrol) then
  48.     return #notcontrol
  49.   end if
  50.   if count(mycontrol) < 2 then
  51.     return #notcontrol
  52.   end if
  53.   set hitlist to getAt(mycontrol, 1)
  54.   if not listp(hitlist) then
  55.     return #notcontrol
  56.   end if
  57.   set actionlist to getAt(mycontrol, 2)
  58.   if not listp(actionlist) then
  59.     return #notcontrol
  60.   end if
  61.   if (count(actionlist) <> count(hitlist)) or (count(hitlist) = 0) then
  62.     return #badcontrol
  63.   end if
  64.   repeat with i = 1 to count(hitlist)
  65.     if inside(hitpoint, getAt(hitlist, i)) then
  66.       puppetSprite(hiliterect, 0)
  67.       set the locV of sprite 2 to getAt(actionlist, i)
  68.       repeat with spriteNum = 2 to endSprite - 1
  69.         setlistposition()
  70.       end repeat
  71.       exit repeat
  72.     end if
  73.   end repeat
  74. end
  75.  
  76. on checkroomrollover whichway
  77.   set noroll to 1
  78.   repeat with i = hiliterect - 1 down to 1
  79.     if rollOver(i) then
  80.       if (listp(getAt(groommouseupslist, i)) and ((whichway = #up) or (whichway = #both))) or (listp(getAt(groommousedownslist, i)) and ((whichway = #down) or (whichway = #both))) then
  81.         hiliteroomcontrol(i, whichway)
  82.         set noroll to 0
  83.         exit repeat
  84.       end if
  85.     end if
  86.   end repeat
  87.   if noroll then
  88.     set the locH of sprite hiliterect to -1000
  89.   end if
  90. end
  91.  
  92. on hiliteroomcontrol contnum, whichway
  93.   set norect to 1
  94.   if (whichway = #up) or (whichway = #both) then
  95.     set upcont to getAt(groommouseupslist, contnum)
  96.     if not listp(upcont) then
  97.       set uprects to []
  98.     end if
  99.     if count(upcont) < 2 then
  100.       set uprects to []
  101.     end if
  102.     if voidp(uprects) then
  103.       set uprects to getAt(upcont, 1)
  104.     else
  105.       nothing()
  106.     end if
  107.   else
  108.     set uprects to []
  109.   end if
  110.   if (whichway = #down) or (whichway = #both) then
  111.     set downcont to getAt(groommousedownslist, contnum)
  112.     if not listp(downcont) then
  113.       set downrects to []
  114.     end if
  115.     if count(downcont) < 2 then
  116.       set downrects to []
  117.     end if
  118.     if voidp(downrects) then
  119.       set downrects to getAt(downcont, 1)
  120.     else
  121.       nothing()
  122.     end if
  123.   else
  124.     set downrects to []
  125.   end if
  126.   set rectlist to combo(uprects, downrects)
  127.   set hoff to the left of sprite contnum
  128.   set voff to the top of sprite contnum
  129.   set where to point(the mouseH - hoff, the mouseV - voff)
  130.   set mouseposition to point(the mouseH, the mouseV)
  131.   repeat with r in rectlist
  132.     if inside(where, r) and (the mouseH < 425) then
  133.       set order to getOne(rectlist, r)
  134.       set roomhilite to string(getAt(roomlist, order)) && "light"
  135.       set the memberNum of sprite hiliterect to the number of member roomhilite
  136.       spriteBox(hiliterect, getAt(r, 1) + hoff, getAt(r, 2) + voff, getAt(r, 3) + hoff, getAt(r, 4) + voff)
  137.       updateStage()
  138.       set norect to 0
  139.       exit repeat
  140.     end if
  141.   end repeat
  142.   if inside(mouseposition, rect(0, 0, 13, 72)) then
  143.     scrollleft()
  144.   else
  145.     if inside(mouseposition, rect(627, 0, 640, 72)) then
  146.       scrollright()
  147.     else
  148.       cursor(-1)
  149.     end if
  150.   end if
  151.   if norect then
  152.     set the locH of sprite hiliterect to -1000
  153.   end if
  154. end
  155.  
  156. on combo alist, anotherlist
  157.   set rectlist to []
  158.   repeat with r in alist
  159.     if ilk(r, #rect) then
  160.       add(rectlist, r)
  161.     end if
  162.   end repeat
  163.   repeat with r in anotherlist
  164.     if ilk(r, #rect) then
  165.       add(rectlist, r)
  166.     end if
  167.   end repeat
  168.   return rectlist
  169. end
  170.  
  171. on initscrollh
  172.   global timesflag
  173.   set roomscrollpos to 1
  174.   set roomscrolllinesize to 20
  175.   set roombarsprite to 41
  176.   set roomleftofscroll to the left of sprite roombarsprite
  177.   set roomrightofscroll to the right of sprite roombarsprite
  178.   set roomtotalscroll to the width of cast the memberNum of sprite roomcontentsprite
  179.   set roommaxscroll to roomtotalscroll - (roomrightofscroll - roomleftofscroll)
  180.   set timesflag to 1
  181.   setscrollboxh()
  182. end
  183.  
  184. on setscrollboxh
  185.   set the locH of sprite roomcontentsprite to roomleftofscroll + (roomtotalscroll / 2) - roomscrollpos + 1
  186.   updateStage()
  187. end
  188.  
  189. on scrollright
  190.   set roomscrollpos to roomscrollpos + roomscrolllinesize
  191.   if roomscrollpos > roommaxscroll then
  192.     set roomscrollpos to roommaxscroll
  193.     cursor(-1)
  194.   else
  195.     changecursor("Right")
  196.   end if
  197.   setscrollboxh()
  198. end
  199.  
  200. on scrollleft
  201.   set roomscrollpos to roomscrollpos - roomscrolllinesize
  202.   if roomscrollpos < 1 then
  203.     set roomscrollpos to 1
  204.     cursor(-1)
  205.   else
  206.     changecursor("Left")
  207.   end if
  208.   setscrollboxh()
  209. end
  210.